<?php
if ($_SESSION['niveauAuth']=='1' or $_SESSION['niveauAuth']=='2'or $_SESSION['niveauAuth']=='3' or $_SESSION['niveauAuth']=='4'or $_SESSION['niveauAuth']=='5'or $_SESSION['niveauAuth']=='6'or $_SESSION['niveauAuth']=='7' or $_SESSION['niveauAuth']=='8'or $_SESSION['niveauAuth']=='9') {
/**
 * Controleur permettant de lister l'ensemble des clients
 */
require_once('dao/ClientDao.php');
require_once('dao/CommandeDao.php');

if (isset($_GET['delete']) and $_GET['delete']=='ok'){
	Dao::delete('commande','id = '.$_GET['id'].' ');
	Dao::delete('ligne_commande','id_commande = '.$_GET['id'].' ');
	Dao::delete('ligne_commande_om','id_ligne_commande = '.$_GET['id'].' ');
}

if (isset($_GET['code_client_hto'])){
	
	// Chargement des commandes pour un seul client
	$commandes = CommandeDao::findByCodeClient($_GET['code_client_hto']);
	} else {

	// Chargement de l'ensemble des commande clients
	$commandes = CommandeDao::getAllRS();
}



// Rendu de la page
	echo $twig->render('liste-commande.html',
			array(	'commandes' => $commandes,
					'message' => $message,
					'error' => $error));
	}
	else {
		redirect("home-admin");
	}
